
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<c:set var="listproductscart" scope="session"
	value="${sessionScope.listproductscart}" />
<c:choose >
	<c:when test="${listproductscart.size() > 0}">
	<form name="listproductscart" action="Cart.do" method="get">
	<table  width="100%" border="1" cellspacing="0" cellpadding="5">
		<tr bgcolor="#666666">
			<td class="bgColorMain"><strong><font
					color="#FFFFFF">CART</font></strong></td>
		</tr>
		<tr>
			<td>
				<table width="100%" border="1" cellspacing="0" cellpadding="5">
					<tr align="center" class="firstrowtable">
						<td width="6%"><strong>ORDER NUMBER</strong></td>
						<td width="10%"><strong>IMAGE</strong></td>
						<td><strong>PRODUCT NAME</strong></td>
						<td width="15%"><strong>QUANTITY</strong></td>
						<td width="15%"><strong>PRICE</strong></td>
						<td width="15%"><strong>TOTAL</strong></td>
						<td width="10%"><strong>DELETE</strong></td>
					</tr>
					<c:set var="sumprice" value="0" />
					<c:set var="estimatetax" value="0" />
					<c:if test="${listproductscart.size() > 0}">
						<c:forEach var="i" begin="0" end="${listproductscart.size()-1}">
							<c:set var="pr" value="${listproductscart[i]}" />
							<c:set var="sumprice"
								value="${sumprice + pr.price*pr.quantityforsell}" />
								<c:set var="estimatetax"
								value="${estimatetax + pr.price*pr.quantityforsell*pr.tax/100}" />
							<tr valign="top">
								<td align="center">${i+1 }</td>
								<td width="9%" align="center"><a
									href="ProductDetail.do?productid=${pr.productid}"><img
										src="<c:url value="${pr.image1}" />" alt="#" width="57" height="85" border="0" /></a></td>
								<td><a href="ProductDetail.do?productid=${pr.productid}">${pr.productname}</a></td>
								<td width="12%"><label for="quantityforsell"></label> <input
									name="quantityforsell" type="text" id="quantityforsell"
									value="${pr.quantityforsell}" size="17" /></td>
								<td align="right">$<fmt:formatNumber type="number"
												value="${pr.price}"
												maxFractionDigits="2"
												minFractionDigits="2"/></td>
								<td align="right">$<fmt:formatNumber type="number"
												value="${pr.quantityforsell*pr.price}"
												maxFractionDigits="2"
												minFractionDigits="2"/></td>
								<td align="center"><a
									href="DeleteProductCart.do?productid=${pr.productid}">Delete</a></td>
							</tr>
						</c:forEach>

					</c:if>
					<tr valign="top">
						<td colspan="5" align="right">Sum Price</td>
						<td colspan="2" align="center"><strong><font
								color="#FF0000">$<fmt:formatNumber type="number"
												value="${sumprice}"
												maxFractionDigits="2"
												minFractionDigits="2"/></font></strong></td>
					</tr>
					<tr valign="top">
						<td colspan="5" align="right">Estimate tax</td>
						<td colspan="2" align="center"><strong><font
								color="#FF0000">$<fmt:formatNumber type="number"
												value="${estimatetax}"
												maxFractionDigits="2"
												minFractionDigits="2"/></font></strong></td>
					</tr>
				</table> <br />
				<table width="100%">
					<tr valign="top" style="background-color:#ffffff;">
						<td align="center"><a href="Products.do"><img
								src="/SpringMVCExample/resources/images/continueshopping.png" alt="#" border="0" /></a></td>
						<td align="center"><input type="image"
							src="/SpringMVCExample/resources/images/updatequantity.png" name="update" /></td>
						<td align="center"><input type="image"
							src="/SpringMVCExample/resources/images/checkout.png" name="checkout" /></td>
					</tr>
				</table>

			</td>
		</tr>
	</table>
</form>
	</c:when>

	<c:otherwise>
	<table  width="100%" border="1" cellspacing="0" cellpadding="5">
			<tr bgcolor="#666666">
				<td class="bgColorMain"><strong><font
						color="#FFFFFF">No product in Cart! Press <a style="color:red" href="Products.do">here</a> to continue shopping</font></strong></td>
			</tr>
	</table>
	</c:otherwise>
</c:choose>